package com.nullpointer.xchatfinal.object;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

public class SelectFriend {
	private String userID;
	private String userName;
	private String avatarID;
	private boolean isChecked = false;

	public String getAvatarID() {
		return avatarID;
	}

	public void setAvatarID(String avatarID) {
		this.avatarID = avatarID;
	}

	public String getUserID() {
		return userID;
	}

	public void setUserID(String userID) {
		this.userID = userID;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public boolean isChecked() {
		return isChecked;
	}

	public void setChecked(boolean isChecked) {
		this.isChecked = isChecked;
	}

	public String toJson() {
		return new JSONSerializer().exclude("*.class").deepSerialize(this);
	}

	public static SelectFriend fromJsonToSelectFriend(String json) {
		return new JSONDeserializer<SelectFriend>().use(null,
				SelectFriend.class).deserialize(json);
	}

	public static String toJsonArray(Collection<SelectFriend> collection) {
		return new JSONSerializer().exclude("*.class")
				.deepSerialize(collection);
	}

	public static Collection<SelectFriend> fromJsonArrayToSelectFriends(
			String json) {
		return new JSONDeserializer<List<SelectFriend>>()
				.use(null, ArrayList.class).use("values", SelectFriend.class)
				.deserialize(json);
	}

}
